<template>
	<view class="tab">
		<view v-for="(item, index) in list" :key="index">
			<view @click="gotoDetail(item.id)" class="item" v-if="Math.random() > 0.3">
				<view class="title">{{item.title}}
				</view>
				<view class="imgs">
					<image class="image" v-for="(item2, index2) in item.imgs" :key="index2" :src="item2"></image>
				</view>
				<view class="pl">
					{{item.pl}}评论&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{item.category}}
				</view>
			</view>
			<view @click="gotoDetail(item.id)" class="item2" v-else>
				<view class="content">
					<view class="title">
						{{item.title}}
					</view>
					<view class="pl">
						{{item.pl}}评论&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{item.category}}
					</view>
				</view>
				<image class="image" :src="item.imgs[0]"></image>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		name: "b-tab",
		props: ['list'],
		data() {
			return {

			};
		},
		methods: {
			gotoDetail(id) {
				uni.navigateTo({
					url: '../../pages/detail/detail?id=' + id
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.tab {
		padding: 0 20rpx;

		.item {
			border-bottom: 2rpx solid #eee;

			.title {
				margin: 10rpx 0;
			}

			.imgs {
				display: flex;
				justify-content: space-between;

				.image {
					width: 30vw;
					height: 30vw;
				}
			}

			.pl {
				margin: 10rpx 0;
			}
		}

		.item2 {
			display: flex;
			justify-content: space-between;
			border-bottom: 2rpx solid #eee;
			padding: 6px 0;

			.content {
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				.title {
					margin: 10rpx 0;
				}

				.pl {
					margin: 10rpx 0;
				}
			}

			.image {
				width: 30vw;
				height: 30vw;
				flex-shrink: 0;
			}
		}
	}
</style>
